<template>
  <div class="right">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-table :data="rightList" border style="width: 100%" class='mt-15' v-loading='loading'>
      <el-table-column type="index" width="50">
      </el-table-column>
      <el-table-column prop="authName" label="权限名称">
      </el-table-column>
      <el-table-column prop="path" label="路径">
      </el-table-column>
      <el-table-column label="层级">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.level === '0'">
            {{scope.row.level | filterLevel}}
          </el-tag>
          <el-tag v-else-if="scope.row.level === '1'" type='success'>
            {{scope.row.level | filterLevel}}
          </el-tag>
          <el-tag v-else type="warning">
            {{scope.row.level | filterLevel}}
          </el-tag>
        </template>
      </el-table-column>

    </el-table>
  </div>
</template>
<script>
import {getRights} from '@/api'
export default {
  data () {
    return {
      rightList: [],
      loading: true
    }
  },
  created () {
    this.initTable()
    this.loading = false
  },
  filters: {
    filterLevel (level) {
      if (level === '0') {
        return '一级'
      } else if (level === '1') {
        return '二级'
      } else {
        return '三级'
      }
    }
  },
  methods: {
    initTable () {
      getRights('list')
        .then(res => {
          console.log(res)
          this.rightList = res.data
        })
    }

  }
}
</script>
